//引入express模块
const express = require('express');
const path = require('path');
//创建应用对象
const app = express();
//引入数据库
require('./db')
//添加管理员路由引入
const addAdminRoute=require("./routes/addAdmin")
const adminListRoute=require("./routes/adminList")
const deleteAdminRoute=require("./routes/deleteAdmin")
const loginRoute=require('./routes/login')
const isLoginRoute=require('./routes/isLogin')
const logoutRoute=require("./routes/logout")
const addAdvRoute=require('./routes/addAdv');
const advListRoute= require('./routes/advList');
const deleteAdvRoute=require('./routes/deleteAdv');
const getUpdateDataRoute = require('./routes/getUpdateData');
const setUpdateDataRoute = require('./routes/setUpdateData');
//启动解析json，form表单格式的中间件
app.use(express.json())
app.use(express.urlencoded({
  extended:false
}))
//添加管理员的接口
app.use(addAdminRoute)
//查询管理员列表的接口
app.use(adminListRoute)    
app.use(deleteAdminRoute)
app.use(loginRoute) 
app.use(isLoginRoute)
app.use(logoutRoute)
app.use(addAdvRoute)
app.use(advListRoute)
app.use(deleteAdvRoute)
app.use(getUpdateDataRoute)
app.use(setUpdateDataRoute)
//图片的静态资源，第一个参数限制文件
app.use('/upload',express.static(path.resolve(__dirname,"./upload")))
app.listen(8000, () => {
  console.log("服务器启动成功 http://127.0.0.1:8000");
})